<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
${aier_doctype}
<html <s:property value="aier_html_xmlns" escape="false"/>>
<head>
<meta http-equiv="Content-Type" content="${aier_content_type}" />
<meta name="keywords" content="${aier_keyworks}" />
<meta name="description" content="${aier_description}" />
<link rel="stylesheet" href="${aier_css_url}${aier_jqui_css}ui.css" />
<link href="${aier_css_url}jq/jq.css" rel="Stylesheet" />
<link rel="stylesheet" href="${aier_css_url}${aier_jqui_css}text.css" />
<link rel="stylesheet" href="${aier_css_url}${aier_jqui_css}enhanced.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/jq-msg.css" />
<link rel="stylesheet" href="${aier_css_url}proxy/cm.css" />

<script type="text/javascript" src="${aier_js_url}j.js"></script>
<script type="text/javascript" src="${aier_js_url}b.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/hh/ui.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/cn.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/jq.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/arrayList.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/msg.js"></script>
<script type="text/javascript" src="${aier_js_url}${aier_jqui_js}custominput.js"></script>
<script type="text/javascript" src="${aier_js_url}${aier_jqui_js}text.js"></script>
</head>
<script type="text/javascript">
	function gridDate() {
		$("#classinfo")
				.jqGrid(
						{
							datatype : "local",
							colNames : [ '班级名称', '更新', '移除' ],
							colModel : [ {
								name : 'cname',
								index : 'cname',
								width : 400
							}, {
								name : 'update',
								index : 'update',
								width : 80,
								align : 'center',
								sortable : false
							}, {
								name : 'remove',
								index : 'remove',
								width : 80,
								align : 'center',
								sortable : false
							},

							],
							//autowidth:true,

							pager : jQuery("#classpage"),
							//prmNames : {page:"page",sort: "sort"},
							rowNum : 10,
							//rowList: [10, 20, 30],
							sortname : 'cname',
							hidegrid : false,
							sortorder : 'asc',
							viewrecords : true,
							caption : '班级管理',
							gridComplete : function() {
								var ids = jQuery("#classinfo").jqGrid(
										'getDataIDs');
								for ( var i = 0; i < ids.length; i++) {
									var id = ids[i];
									var up = "<a href='javascript:;' style='color:#f60' onclick='upDiv("
											+ id + ")' >修改</a>";
									var del = "<a href='javascript:;' style='color:#f60' onclick='delTel("
											+ id + ")'>删除</a>";
									jQuery("#classinfo").jqGrid('setRowData',
											ids[i], {
												update : up,
												remove : del
											});
								}
							}
						}).navGrid("#classpage", {
					edit : false,
					add : false,
					del : false,
					search : false
				});
		//单行添加数据
		$("#b_addUpdate").click(function() {
			if (!isnull($("#txt_cName").val())) {
				var ids = jQuery("#classinfo").jqGrid('getDataIDs');
				var i;
				if (!isnull(ids)) {
					i = ids.length + 1;
				} else {
					i = 1;
				}
				jQuery("#classinfo").jqGrid('addRowData', i, {
					cname : $("#txt_cName").val()
				});

				$().message("添加成功");
			} else {
				$().message("请输入班级！");
			}

		});

		$('#but_next')
				.click(
						function() {

							//获得班级名称
							var gr = jQuery("#classinfo").jqGrid('getRowData');
							var cnames = "";
							for ( var i = 0; i < gr.length; i++) {
								if (i == (gr.length - 1)) {
									cnames += gr[i].cname;
								} else {
									cnames += gr[i].cname + ",";
								}

							}

							var fun = function(data) {
								if (10001 == data.s) {
									location.href = "${aier_url}proxy/creates_assignCards${aier_suffix}?pid=${pid}";
								}
							};
							exeAjax(
									ajaxUrl("${aier_url}${aier_urijs}quicksc_addclasslist${aier_suffix}"),
									fun, {
										"cnames" : cnames,
									});

						});
		loadCDates();
		function loadCDates() {
			var fun = function(data) {
				if (10001 == data.s) {
					var cmdates = data.cnames;
					if (!isnull(cmdates) && cmdates.split(",").length > 0) {
						for ( var i = 0; i < cmdates.split(",").length; i++) {
							var li = cmdates.split(",")[i];

							jQuery("#classinfo").jqGrid('addRowData', i + 1, {
								cname : li
							});
						}
					}
				}
			};
			exeAjax(
					ajaxUrl("${aier_url}${aier_urijs}quicksc_selectlist${aier_suffix}"),
					fun, {

					});

		}
	}

	function delTel(id) {
		var su = jQuery("#classinfo").jqGrid('delRowData', id);
		if (su) {
			$().message("删除成功");
		}
	}
</script>
<body>
	<div id="tabs">
		<ul>
			<li><a href="#tabs-1">班级管理</a>
			</li>
		</ul>
		<div id="tabs-1" style="height: 500px;">
			<div class="d_content">
				<div class="d_scnOut">
					<div class="d_scname">
						<label for="txt_cName">班级名称:</label>
					</div>
					<div class="d_sctext">
						<input type="text" id="txt_cName">
					</div>
					<button id="b_addUpdate"
						style="margin-left: 260px;margin-top: -40px;"
						class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"
						role="button" aria-disabled="false">
						<span class="ui-button-text">添加</span>
					</button>

				</div>
				<table id="classinfo"></table>
				<div id="classpage"></div>



				<button id="but_previous"
					style="margin-left: 300px;margin-top: 20px;"
					class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"
					role="button" aria-disabled="false">
					<span class="ui-button-text">上一步</span>
				</button>
				<button id="but_next" style="margin-left: 100px;margin-top: 20px;"
					class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"
					role="button" aria-disabled="false">
					<span class="ui-button-text">下一步</span>
				</button>
				
				<div id="d_amNUpdate" title="修改班级名称" style="display: none;">
					<div class="d_scnOut">
						<div class="d_scname">
							<label for="txt_cmupName">班级名称:</label>
						</div>
						<div class="d_sctext">
							<input type="text" id="txt_cmupName">
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
	gridDate();

	$("#tabs").tabs();
	$('#but_previous')
			.click(
					function() {
						location.href = "${aier_url}proxy/creates_attendanceGrade${aier_suffix}";
					});

	// 弹出层
	function upDiv(id) {
		$(function() {

			$("#d_amNUpdate").dialog(
					{
						//hide : "explode",
						resizable : false,
						height : 250,
						width : 450,
						modal : true,
						buttons : {
							"确定" : function() {
								var su = jQuery("#classinfo").jqGrid(
										'setRowData', id, {
											cname : $("#txt_cmupName").val()
										});
								if (su) {
									$(this).dialog("close");

								}
							}
						}
					});
		});
	}
</script>
</html>